/*
 * Copyright @ 2013 com.iflysse.trains
 * mySchedule 下午8:16:30
 * All right reserved.
 *
 */
package com.iflysse.utils;

import java.util.List;

import com.alibaba.fastjson.JSONObject;

/**
 * 分页
 * 
 * @desc: weixin
 * @author: junhan
 * @createTime: 2013年11月7日 下午8:16:30
 * @history:
 * @version: v1.0
 * @param <T>
 */
public class PagerBean<T> {
	/**
	 * 默认当前页
	 */
	private int page;
	
	/**
	 * 每页大小
	 */
	private int pageSize;
	/**
	 * 查询的结果总数
	 */
	private long total;
	
	/**
	* 对象查询参数
	*/
	private T param;
	/**
	 * 每页的分页数据
	 */
	private List<T> rows;
	
	/**
	  * 总页数
	  */	
	private int totalPage;

	/**
	  * 排序依据
	  */
	private String mysort;

	/**
	  * 排序方式
	  */
	private String myorder;
	
	
	/**
	 * @return the mysort
	 */
	public String getMysort() {
		return mysort;
	}

	/**
	 * @param mysort the mysort to set
	 */
	public void setMysort(String mysort) {
		this.mysort = mysort;
	}

	/**
	 * @return the myorder
	 */
	public String getMyorder() {
		return myorder;
	}

	/**
	 * @param myorder the myorder to set
	 */
	public void setMyorder(String myorder) {
		this.myorder = myorder;
	}

	public int getPage() {
		return page;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPage(int page) {
		this.page = page;
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize
	 *            the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the total
	 */
	public long getTotal() {
		return total;
	}

	/**
	 * @param total
	 *            the total to set
	 */
	public void setTotal(long total) {
		this.total = total;
	}

	/**
	 * @return the rows
	 */
	public List<T> getRows() {
		return rows;
	}

	/**
	 * @param rows
	 *            the rows to set
	 */
	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	
	public int getTotalPage() {
		this.totalPage = (int)this.total%this.pageSize!=0?(int)this.total/this.pageSize+1:(int)this.total/this.pageSize; 
		return totalPage;
	}

	public T getParam() {
		return param;
	}

	public void setParam(T param) {
		this.param = param;
	}

	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}

}
